<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title>中经汇通</title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <link rel="stylesheet" href="__STATICS__/css/jquery-ui-date.min.css"/>
        <link rel="stylesheet" href="__STATICS__/css/jquery-ui-date.theme.min.css"/>
            
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>

    </head>
    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('Houtai/Index/index')}">首页</a> </li>
                        <li class="">订单管理</li>
                        <li class="active">基本订单列表</li>
                    </ul>
                    <div role="tabpanel">
                        
                        <div class="row clearfix margin10 form-horizontal">
                            <form  name="query" >
                                <span class="pull-left ml30 form_bar">查询：</span>
                                <div class="col-md-2">
                                    <input type="text" name="orderSn" value="{$Think.request.sOrderSn}" placeholder=" 订单编号" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <input type="text" name="userPhone" value="{$Think.request.userPhone}" placeholder=" 账号(手机号)" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <input type="text" name="liushui" value="{$Think.request.liushui}" placeholder=" 支付流水号" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <select  name="sStatus" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sStatus" value="-1" > selected </eq> >-订单状态-</option>
                                            <option value="0" <eq name="Think.request.sStatus" value="0" > selected </eq> >未付款</option>
                                            <option value="1" <eq name="Think.request.sStatus" value="1" > selected </eq> >已付款</option>
                                            <option value="2" <eq name="Think.request.sStatus" value="2" > selected </eq> >已完成</option>
                                            <option value="3" <eq name="Think.request.sStatus" value="3" > selected </eq> >已取消</option>
                                    </select>
                                </div>
                                <div style="clear: both; margin: 10px 0px;"></div>
                                <span class="pull-left ml30 form_bar">付款时间：</span>
                                <div class="col-md-3">
                                    <input type="text" name="startPayTime" value="{$Think.request.startPayTime}" class="datepicker form-control" />
                                </div>
                                <div class="col-md-3">
                                    <input type="text" name="endPayTime" value="{$Think.request.endPayTime}" class="datepicker form-control" />
                                </div>
                                <div style="clear: both; margin: 10px 0px;"></div>
                                <span class="pull-left ml30 form_bar">订单时间：</span>
                                <div class="col-md-3">
                                    <input type="text" name="startAddTime" value="{$Think.request.startAddTime}" class="datepicker form-control" />
                                </div>
                                <div class="col-md-3">
                                    <input type="text" name="endAddTime" value="{$Think.request.endAddTime}" class="datepicker form-control" />
                                </div>
                                <input type="hidden" name="p" value="1" />
                                <button type="submit" class="pull-left btn btn-default ml20">
                                    搜索
                                </button>
                            </form>
                            <div class="pull-right">
                                    <button id="export_excel" class="pull-left btn btn-orange ml20">
                                        导出
                                    </button>
                            </div>
                        </div>

                        <table class="table table-striped table_qrcode">
                            <!--<caption>标题</caption>-->
                            <thead>
                                <tr class="border">
                                    <th>订单号</th>
                                    <th>账号(手机号)</th>
                                    <th>商品名称</th>
                                    <th>件数</th>
                                    <th>子件数</th>
                                    <th>支付流水号</th>
                                    <th>订单总价</th>
                                    <th>应付价格</th>
                                    <th>订单状态</th>
                                    <th>是否评论</th>
                                    <th>支付方式</th>
                                    <th>订单时间</th>
                                    <th>付款时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="list" id="vo">
                                    <tr class="qr_tar">
                                        <td>{$vo.orderSn}</td>
                                        <td>{$vo.userPhone}</td>
                                        <td><volist name="vo.goodsList" id="vo1" >
                                                {$vo1.goodsName}&nbsp;
                                            </volist></td>
                                        <td>{$vo.numOfPack}</td>
                                        <td>{$vo.nums}</td>
                                        <td>
                                            <if condition="$vo['liushui'] gt 0" >
                                            {$vo.liushui}
                                            <else />
                                            无
                                            </if>
                                            </td>
                                        <td>{$vo.totalPrice}</td>
                                        <td>{$vo.payPrice}</td>
                                        <td class="text-success ">
                                            <switch name="vo.status" >
                                                <case value="0"><span class="text-warning"> 未付款</span></case>
                                                <case value="1"><span class="text-blue ">已付款</span></case>
                                                <case value="2"><span class="text-success ">已完成</span></case>
                                                <case value="3"><span class="text-danger">已取消</span></case>
                                            </switch>
                                        </td>
                                        <td>
                                            <switch name="vo.isComment" >
                                                <case value="0" >未评论</case>
                                                <case value="1">已评论</case>
                                            </switch>
                                        </td>
                                        <td>{$vo.payModeName}</td>
                                        <td>{$vo.addTime|date="Y/m/d H:i:s",###} </td>  
                                        <td><if condition="$vo['payTime'] gt 0" >
                                            {$vo.payTime|date="Y/m/d H:i:s",###} 
                                            <else />
                                            无
                                            </if>
                                        </td>
                                        <td data-id="{$vo.orderID}"><a href="javascript:void(0)" class="edit_look" >查看</a>
                                        </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>

                        <div class="clearfix s_page pull-right">
                            {$page}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content ">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"> </h4>
                    </div>
                    <div class="modal-body">
                        
                        <div class="clearfix">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        下单时间：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="addTime"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        订单编号：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="orderSn"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        订单总价：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="totalPrice"></span>
                                    </div>
                                 </div>
                         
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        已付价格：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="payPrice"></span>
                                    </div>
                                </div>
                             <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                       用户昵称：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="nickName"></span>
                                    </div>
                                </div>
                                 <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        用户手机号：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="phone"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        商店名称：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="shopName"></span>
                                    </div>
                                </div>                         
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                         商店地址：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="address"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        优惠券名称：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="couponName"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        商品名称：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="goodsName"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        是否已评论：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="isComment"></span>
                                    </div>
                                </div>
                                <div class="col-md-12 margin10">
                                    <div class="col-md-3 text_right form_bar">
                                        支付方式名称：
                                    </div>
                                    <div class="col-md-6">
                                        <span id="payModeName"></span>
                                    </div>
                                </div>                               
                            </div>
                        
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:void(0);" class="btn btn-primary" id="ok" >确定</a>
                    </div>
                </div>
            </div>
        </div>       

        <include file="Include/script" />
        <script src="__STATICS__/js/jquery-ui-date.min.js"></script>

        
        <script>
            var reload = false;
            var img_url = "__STATICS__/images";
             var ajaxData = {};
             ajaxData.ajax = 1;
             ajaxData.sStatus = 1;
             ajaxData.p = 1;
             ajaxData.totalPage = 0;//页的总数
             ajaxData.totalCount = 0;//数据总数
            
            /*菜单展开及高亮*/
            $(function () {
                
            	$('.order').addClass('open');
                $('#order1').addClass('active');
                
                $('.datepicker').datepicker();

                $('#myModal').on('hidden.bs.modal', function (e) {
                    if(reload) {
                        window.location.reload();
                    }
                        reset_display();
                 });

                $(".edit_look").on("click", function () {
                    var orderID = $(this).closest("td").attr("data-id");
                    var jsonData = {};
                    jsonData.orderID = orderID;
                    ajax_go_1(jsonData,"{:U('CNEPAdmin/Order/orderMsg')}",onEdit);
                    
                });
                
                                
                function onEdit(rsp) {
                    if(rsp.result > 0) {
                    	$("#orderID").val(rsp.info.orderID);
                        $("#orderSn").html(rsp.info.orderSn);
                         $("#totalPrice").html(rsp.info.totalPrice);
                         $("#payPrice").html(rsp.info.payPrice + " 元");
                         $("#addTime").html(rsp.info.addTime);
                         $("#nickName").html(rsp.info.nickName);
                         $("#phone").html(rsp.info.phone);
                         $("#shopName").html(rsp.info.shopName);
                         $("#address").html(rsp.info.address);
                         $("#isComment").html(rsp.info.isComment);
                         $("#payModeName").html(rsp.info.payModeName);
                         var goodsArr = rsp.goods;
//                         console.log(goodsArr);
                         if(goodsArr){
                                 var goodsStr = [];
                                 for(var i=0;i<goodsArr.length;i++){
                                      goodsStr.push(goodsArr[i].goodsName);
                              }
                              $("#goodsName").html(goodsStr.join('，'));
                         }
                         
                         var couponArr = rsp.coupon;
//                         console.log(couponArr);     
                         if(couponArr){
                                 var couponStr = [];
                                 for(var i=0;i<couponArr.length;i++){
                                     couponStr.push(couponArr[i].couponName);
                                 }
                                 tmpStr = couponStr.join('，'); 
                                 if(tmpStr.length > 0)  $("#couponName").html(tmpStr);
                                 else $("#couponName").html('无');
                         }
                          
                         $("#myModalLabel").html("订单详情 (" +rsp.info.orderSn + " " +rsp.info.statusStr + " / " + rsp.info.isComment+ ")");
                         $('#myModal').modal(); // 跳出弹窗
                    } else {
                    	swal('操作失败;' + rsp.desc,'','warning');	
                    }
                   
                }
                
                
                /*取消订单*/
                $("#export_excel").on("click", function () {
                    
                        var self = $(this);
                        swal({   title: "您确定吗?",
                                    text: "您将导出Excel表单！",
                                    type: "warning",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "是的",
                                    cancelButtonText: "放弃",
                                    closeOnConfirm: true
                                },
                                function (isConfirm) {
                                    if (isConfirm) {
                                        var param = "orderSn={$Think.request.orderSn}&liushui={$Think.request.liushui}&userPhone={$Think.request.userPhone}&sLogisticsStatus={$Think.request.sLogisticsStatus}&sStatus={$Think.request.sStatus}&startPayTime={$Think.request.startPayTime}&endPayTime={$Think.request.endPayTime}&startAddTime={$Think.request.startAddTime}&endAddTime={$Think.request.endAddTime}";
                                        window.location.href = "{:U('CNEPAdmin/Excel/orderReport')}?sOrderType={$Think.request.sOrderType}&"+param;
                                    }

                                });
                });
                
                
                $("#ok").on("click",function(){
                     $('#myModal').modal('hide')
                });

                /*清空弹出框内容*/
                function reset_display()
                {
                    $("#orderID").html('');
                    $("#orderSn").html('');
                    $("#totalPrice").html('');
                    $("#payPrice").html('');
                    $("#addTime").html('');
                    $("#nickName").html('');                 
                    $("#phone").html('');
                    $("#shopName").html('');
                    $("#address").html('');
                    $("#isComment").html('');
                    $("#payModeName").html('');
                    $("#goodsName").html('');
                    $("#couponName").html('');                  
                    $($('.btn-group .btn-warning')[0]).click();
                    $("#masterAction").attr("disabled",false);

                }
                });   
           
        </script>
    </body>
</html>